package com.code.coinprice.exceptions;

/**
 * 自定义异常
 */
public class BizException extends RuntimeException {

    private static final long serialVersionUID = -2732588474539601022L;

    private int errno = 600;

    private String errmsg;

    public BizException() {
    }

    public BizException(int errno) {
        super();
        this.errno = errno;
    }

    public BizException(String errmsg) {
        super();
        this.errmsg = errmsg;
    }

    public BizException(int errno, String errmsg) {
        super();
        this.errno = errno;
        this.errmsg = errmsg;
    }

    public int getErrno() {
        return errno;
    }

    public void setErrno(int errno) {
        this.errno = errno;
    }

    @Override
    public String getMessage() {
        return errmsg;
    }

    /**
     * 未登录异常
     *
     * @return 异常
     */
    public static BizException unLogin() {
        return new BizException(501, "501");
    }

    /**
     * 参数错误异常
     *
     * @return 异常
     */
    public static BizException badArgumentValue() {
        return new BizException(402, "402");
    }

    /**
     * 无权限错误异常
     *
     * @return 异常
     */
    public static BizException noAuthority() {
        return new BizException(401, "无权限");
    }

    /**
     * 数据更新失败
     *
     * @return 异常
     */
    public static BizException updatedDataFailed() {
        return new BizException(505, "505");
    }
}
